<!--
 * @Author: your name
 * @Date: 2022-03-14 15:25:46
 * @LastEditTime: 2022-03-14 16:30:19
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geyao\geyao\异步和同步转换220314.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>异步和同步转换</title>
</head>

<body>
  <script>
    // 假设场景两个函数

    // function fangfang() {
    //   setTimeout(() => {
    //     console.log("我给你钱")
    //   },1000)
    // }
    // function geyao() {
    //   setTimeout(() => {
    //     console.log("我去买东西")
    //   },500)
    // }
    // fangfang();
    // geyao();
   
    //我必须拿到钱 才去买东西 然后买好了
    function fangfang(geyao) {
      setTimeout(() => {
        console.log("我给你钱")
        geyao(kangkang)
      },1000)
    }
    function geyao(kangkang) {
      setTimeout(() => {
        console.log("我去买东西")
        kangkang()
      },500)
    }
      function kangkang() {
      setTimeout(() => {
        console.log("我买好了")
      },500)
    }


    fangfang(geyao)
    
  </script>
</body>

</html>